package com.ququ.syb.business.payment.pubs;

import com.alibaba.fastjson.JSON;
import com.ququ.common.result.ResultJson;
import com.ququ.common.utils.OkHttpClientUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ApiClient {

    private Logger logger = LoggerFactory.getLogger(ApiClient.class);

    public Object apiClient(String apiUrl, Map<String,Object> params){
        logger.debug("apiurl={},参数:{}", apiUrl,params);
        String result = OkHttpClientUtil.post(apiUrl,params,null);
        ResultJson resultJson = JSON.parseObject(result,ResultJson.class);
        if (resultJson.getStatus() == 1)
            return resultJson.getData();
        else
            return null;
    }


    public ResultJson ApiClient(String apiUrl, Map<String,Object> params){
        logger.debug("apiurl={},参数:{}", apiUrl,params);
        String result = OkHttpClientUtil.post(apiUrl,params,null);
        ResultJson resultJson = JSON.parseObject(result,ResultJson.class);
        return resultJson;
    }

}
